Array.prototype.myPop = function() {
    if (this.length === 0) {
        return undefined;
    } else {
        var last = this[this.length - 1];
        this.length--;
        return last;
    }
}

// var arr = [1, 2, 3, 4];
// var res = arr.myPop();
// console.log(arr);
// console.log(res);